# Copyright (c) 2024, NVIDIA CORPORATION.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

target_link_libraries(modules_interface
    INTERFACE
        dcgm_interface
        module_common_interface
        module_common_interface)

target_include_directories(modules_interface
    INTERFACE
        "${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(modules_objects
    PUBLIC
        modules_interface
        module_common_objects)

target_sources(modules_objects
    PRIVATE
        DcgmModuleApi.cpp
        DcgmModule.cpp
        core/DcgmModuleCore.cpp)

function(define_dcgm_module lib_name)
    target_link_libraries(${lib_name}
      PRIVATE
        dcgm
        dcgm_common
        dcgm_logging
        dcgm_mutex
        fmt::fmt
        modules_objects)

    target_compile_definitions(${lib_name} PRIVATE DCGM_API_EXPORT=1)
    target_link_options(${lib_name} PRIVATE -Wl,--version-script,${PROJECT_SOURCE_DIR}/modules/dcgm_modules.linux_def)
endfunction()

add_subdirectory(common)
add_subdirectory(config)
add_subdirectory(diag)
add_subdirectory(health)
add_subdirectory(introspect)
add_subdirectory(nvswitch)
add_subdirectory(policy)
add_subdirectory(profiling)
add_subdirectory(sysmon)
add_subdirectory(vgpu)
